package com.hele.sts.action.admin;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hele.sts.dao.QUser;
import com.hele.sts.dao.QUserDao;
import com.hele.sts.pub.StringUtil;
import com.hele.sts.webwork.PageAction;
import com.opensymphony.xwork2.ActionContext;
public class DocumentListAction
  extends PageAction
{
  static Logger logger = LoggerFactory.getLogger(DocumentListAction.class);
  public static final String LIST = "list";
  public static final String EDIT = "edit";
  public static final String UPDATE = "update";
  public static final String VIEW = "view";
  public static final String DELETE = "del";
  public static final String RESTART = "restart";
  String userId;
  String groupId;
  String userName;
  String passwd;
  String yhlx;
  Date khrq;
  Date cxrq;
  Date ghrq;
  String cxqx;
  String dyqx;
  String bz;
  String errorInfo;
  List qUserList;
  String action;
  String status;
  String operator;
  
  public String execute()
    throws Exception
  {
    ActionContext ctx = ActionContext.getContext();
    Map session = ctx.getSession();
    String loginName = (String)session.get("AdminUser.loginName");
    if ((loginName == null) || (loginName.length() < 1))
    {
      setErrorInfo("没有登录");
      return "error";
    }
    if ((this.action == null) || ("list".equalsIgnoreCase(this.action))) {
      return super.execute();
    }
    return "none";
  }
  
  public String getHref()
  {
    String href = "";
    if ((this.userName != null) && (this.userName.length() > 0)) {
      href = href + "&userName=" + this.userName;
    }
    if ((this.status != null) && (this.status.length() > 0)) {
      href = href + "&status=" + this.status;
    }
    if ((this.yhlx != null) && (this.yhlx.length() > 0)) {
      href = href + "&yhlx=" + this.yhlx;
    }
    return href;
  }
  
  public boolean doCheckInput()
  {
    if ((this.userName == null) || (this.userName.length() < 1))
    {
      setErrorInfo("用户名称必须填写!");
      return false;
    }
    return true;
  }
  
  public int count()
  {
    ActionContext ctx = ActionContext.getContext();
    Map session = ctx.getSession();
    String djjg = (String)session.get("AdminUser.djjg");
    return QUserDao.count(this.userName, this.status, this.yhlx, djjg);
  }
  
  public String list()
  {
    ActionContext ctx = ActionContext.getContext();
    Map session = ctx.getSession();
    String djjg = (String)session.get("AdminUser.djjg");
    this.qUserList = QUserDao.load(this.userName, this.status, this.yhlx, getPageNo(), getPageSize(), djjg);
    return "list";
  }
  
  QUser createQUser()
  {
    QUser bean = new QUser();
    bean.setBz(this.bz);
    bean.setCxqx(this.cxqx);
    bean.setCxrq(this.cxrq);
    bean.setDyqx(this.dyqx);
    bean.setGhrq(this.ghrq);
    bean.setGroupId(this.groupId);
    bean.setKhrq(this.khrq);
    bean.setPasswd(this.passwd);
    bean.setStatus("1");
    if ((this.userId == null) || (this.userId.length() < 1)) {
      this.userId = StringUtil.createUserId();
    }
    logger.debug(this.userId);
    bean.setUserId(this.userId);
    bean.setUserName(this.userName);
    bean.setYhlx(this.yhlx);
    return bean;
  }
  
  public String getUserId()
  {
    return this.userId;
  }
  
  public void setUserId(String userId)
  {
    this.userId = userId;
  }
  
  public String getGroupId()
  {
    return this.groupId;
  }
  
  public void setGroupId(String groupId)
  {
    this.groupId = groupId;
  }
  
  public String getUserName()
  {
    return this.userName;
  }
  
  public void setUserName(String userName)
  {
    this.userName = userName;
  }
  
  public String getPasswd()
  {
    return this.passwd;
  }
  
  public void setPasswd(String passwd)
  {
    this.passwd = passwd;
  }
  
  public String getYhlx()
  {
    return this.yhlx;
  }
  
  public void setYhlx(String yhlx)
  {
    this.yhlx = yhlx;
  }
  
  public Date getKhrq()
  {
    return this.khrq;
  }
  
  public void setKhrq(Date khrq)
  {
    this.khrq = khrq;
  }
  
  public Date getCxrq()
  {
    return this.cxrq;
  }
  
  public void setCxrq(Date cxrq)
  {
    this.cxrq = cxrq;
  }
  
  public Date getGhrq()
  {
    return this.ghrq;
  }
  
  public void setGhrq(Date ghrq)
  {
    this.ghrq = ghrq;
  }
  
  public String getCxqx()
  {
    return this.cxqx;
  }
  
  public void setCxqx(String cxqx)
  {
    this.cxqx = cxqx;
  }
  
  public String getDyqx()
  {
    return this.dyqx;
  }
  
  public void setDyqx(String dyqx)
  {
    this.dyqx = dyqx;
  }
  
  public String getBz()
  {
    return this.bz;
  }
  
  public void setBz(String bz)
  {
    this.bz = bz;
  }
  
  public String getErrorInfo()
  {
    return this.errorInfo;
  }
  
  public void setErrorInfo(String errorInfo)
  {
    this.errorInfo = errorInfo;
  }
  
  public String getAction()
  {
    return this.action;
  }
  
  public void setAction(String action)
  {
    this.action = action;
  }
  
  public List getQUserList()
  {
    return this.qUserList;
  }
  
  public void setQUserList(List qUserList)
  {
    this.qUserList = qUserList;
  }
  
  public String getStatus()
  {
    return this.status;
  }
  
  public void setStatus(String status)
  {
    this.status = status;
  }
  
  public String getOperator()
  {
    return this.operator;
  }
  
  public void setOperator(String operator)
  {
    this.operator = operator;
  }
}
